#ifndef _HTTP_HPP_
#define _HTTP_HPP_

#include <connections.hpp>
#include <map>
using namespace std;

class HTTP
{
private:
  int sock;
  int port;
  int bytes;
  float proto_version;
  string http_server;
  map<string, string> headers;
  bool headers_set;
  struct sockaddr_in server_addr;
  int err;
  /* For response */
  int response;
  bool resp_received;
  string resp_data;

  void get_response();
public:
  static const int GET = 1;
  static const int POST = 2;
  HTTP();
  HTTP(string server, int port);
  HTTP(string server, int port, float proto);
  ~HTTP();
  int connect_to(string server, int port);
  void set_header(string field, string value);
  void fetch(int method, string uri);
  string get_response(bool fetch_headers);
  string get_headers();
};
#endif
